<?php
namespace BP\WF\HttpHandler;
use think\Db;
use NetObjectForPhp\Hashtable;
use BP\Sys\SystemConfig;
use BP\DA\DBAccess;
use \think\Request;
use app\common\controller\DirectoryPageBase;

class WF_Admin_CCBPMDesigner extends DirectoryPageBase{
    function _initialize()
    {
        parent::_initialize();
    }
   function __construct() {

   }
   //驼峰规则,原始传入参数为Login_InitInfo，要转换为：loginInitInfo,取消下划线，首字母大写
	public function loginInitInfo()
	{
            $ht = []; //map
            $ht->add("SysNo",SystemConfig::getConfigValue("SysNo"));
            $ht->add("SysName",SystemConfig::getConfigValue("SysName"));
            $ht->add("EndJSON","0");
            echo(json_encode($ht->data));
	}
	public  function defaultInit(){
        return "{\"RunOnPlant\":\"\",\"SysName\":\"驰骋工作流引擎ccbpm6\",\"CustomerName\":\"驰骋工作流\",\"CustomerNo\":\"CCFlow\",\"SysNo\":\"CCFlow\",\"Msg\":\"\",\"OSModel\":\"1\",\"EndJSON\":\"0\"}";
    }
    public function getWebUserInfo()
    {
        return "{\"RootOfFlow\":\"F0\",\"RootOfDept\":\"0\",\"No\":\"admin\",\"FK_Dept\":\"100\",\"IsAdmin\":\"1\",\"SID\":\"c3a23c81-3d55-41bd-8406-272b03ae8df5\",\"RootOfForm\":\"\",\"Name\":\"admin\",\"EndJSON\":\"0\"}";
    }

    public function letLogin()
    {
        echo "登录成功";
    }
    public function GetFlowTreeTable()
    {
        $sql = "SELECT * FROM (SELECT 'F'+No as NO,'F'+ParentNo PARENTNO, NAME, IDX, 1 ISPARENT,'FLOWTYPE' TTYPE, -1 DTYPE FROM WF_FlowSort
                           union 
                           SELECT NO, 'F'+FK_FlowSort as PARENTNO,(NO + '.' + NAME) as NAME,IDX,0 ISPARENT,'FLOW' TTYPE, 0 as DTYPE FROM WF_Flow) A  ORDER BY IDX";
            /*
            if (BP.Sys.SystemConfig.AppCenterDBType == DBType.Oracle || BP.Sys.SystemConfig.AppCenterDBType == DBType.PostgreSQL)
            {
                sql = @"SELECT * FROM (SELECT 'F'||No as NO,'F'||ParentNo as PARENTNO,NAME, IDX, 1 ISPARENT,'FLOWTYPE' TTYPE,-1 DTYPE FROM WF_FlowSort
                        union 
                        SELECT NO, 'F'||FK_FlowSort as PARENTNO,NO||'.'||NAME as NAME,IDX,0 ISPARENT,'FLOW' TTYPE,0 as DTYPE FROM WF_Flow) A  ORDER BY IDX";
            }*/


            //if (BP.Sys.SystemConfig.AppCenterDBType == DBType.MySQL)
            //{
                $sql = @"SELECT * FROM (SELECT CONCAT('F', No) NO, CONCAT('F', ParentNo) PARENTNO, NAME, IDX, 1 ISPARENT,'FLOWTYPE' TTYPE,-1 DTYPE FROM WF_FlowSort
                           union 
                           SELECT NO, CONCAT('F', FK_FlowSort) PARENTNO, CONCAT(NO, '.', NAME) NAME,IDX,0 ISPARENT,'FLOW' TTYPE, 0 as DTYPE FROM WF_Flow) A  ORDER BY IDX";
            //}

        $data=Db::Query($sql);
        echo json_encode($data);
    }

    public function GetFormTreeTable(){
      /*
        $sqls = "SELECT No,ParentNo,Name, Idx, 1 IsParent, 'FORMTYPE' TType FROM Sys_FormTree ORDER BY Idx ASC ; ";
        $sqls .= "SELECT No, FK_FormTree as ParentNo,Name,Idx,0 IsParent, 'FORM' TType FROM Sys_MapData  WHERE AppType=0 AND FK_FormTree IN (SELECT No FROM Sys_FormTree) ORDER BY Idx ASC";
        echo $sqls;
        $ds=Db::Query($sqls);
        echo json_encode($ds);*/
        //这个实现较为麻烦
      return "[{\"NO\":\"F01.\",\"PARENTNO\":\"F99\",\"NAME\":\"线性流程\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F02.\",\"PARENTNO\":\"F99\",\"NAME\":\"同表单分合流\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F03.\",\"PARENTNO\":\"F99\",\"NAME\":\"异表单分合流\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F04.\",\"PARENTNO\":\"F99\",\"NAME\":\"父子流程\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F05.\",\"PARENTNO\":\"F99\",\"NAME\":\"SDK流程\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F06.\",\"PARENTNO\":\"F99\",\"NAME\":\"压力与速度测试\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F07.\",\"PARENTNO\":\"F99\",\"NAME\":\"单元测试-用例流程\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F08.\",\"PARENTNO\":\"F99\",\"NAME\":\"表单解决方案\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F09.\",\"PARENTNO\":\"F99\",\"NAME\":\"数据列表前置导航\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F100\",\"PARENTNO\":\"F01.\",\"NAME\":\"财务报销流程演示\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F101\",\"PARENTNO\":\"F01.\",\"NAME\":\"会签\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F102\",\"PARENTNO\":\"F01.\",\"NAME\":\"外部用户流程\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F103\",\"PARENTNO\":\"F01.\",\"NAME\":\"审核组件\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F104\",\"PARENTNO\":\"F01.\",\"NAME\":\"多人处理\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F105\",\"PARENTNO\":\"F04.\",\"NAME\":\"经典调用方式\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F106\",\"PARENTNO\":\"F04.\",\"NAME\":\"递归子流程\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F107\",\"PARENTNO\":\"F05.\",\"NAME\":\"请假流程Demo\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F108\",\"PARENTNO\":\"F07.\",\"NAME\":\"跳转\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F109\",\"PARENTNO\":\"F07.\",\"NAME\":\"方向条件\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F110\",\"PARENTNO\":\"F07.\",\"NAME\":\"业务表数据同步\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F111\",\"PARENTNO\":\"F08.\",\"NAME\":\"单表单\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F112\",\"PARENTNO\":\"F08.\",\"NAME\":\"树形表单\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F113\",\"PARENTNO\":\"F08.\",\"NAME\":\"多表单\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F114\",\"PARENTNO\":\"F08.\",\"NAME\":\"公文\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F115\",\"PARENTNO\":\"F08.\",\"NAME\":\"子父流程-前置导航-合卷审批模式\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"F99\",\"PARENTNO\":\"F0\",\"NAME\":\"流程树\",\"IDX\":0,\"ISPARENT\":1,\"TTYPE\":\"FLOWTYPE\",\"DTYPE\":-1},{\"NO\":\"001\",\"PARENTNO\":\"F100\",\"NAME\":\"001.财务报销演示(自由表单)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"002\",\"PARENTNO\":\"F01.\",\"NAME\":\"002.请假流程(按岗位控制走向-自由表单)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"004\",\"PARENTNO\":\"F113\",\"NAME\":\"004.建筑资质申请(多表单流程)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"005\",\"PARENTNO\":\"F02.\",\"NAME\":\"005.月销售总结(同表单分合流)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"006\",\"PARENTNO\":\"F02.\",\"NAME\":\"006.同表单分合流(二)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"007\",\"PARENTNO\":\"F02.\",\"NAME\":\"007.会议通知流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"008\",\"PARENTNO\":\"F02.\",\"NAME\":\"008.以SQL做为子线程的数据源与接受人\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"009\",\"PARENTNO\":\"F03.\",\"NAME\":\"009.部门年计划流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"010\",\"PARENTNO\":\"F03.\",\"NAME\":\"010.新航线考察流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"011\",\"PARENTNO\":\"F105\",\"NAME\":\"011.项目管理(父流程)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"012\",\"PARENTNO\":\"F105\",\"NAME\":\"012.催款流程(子流程)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"013\",\"PARENTNO\":\"F105\",\"NAME\":\"013.施工流程(子流程)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"014\",\"PARENTNO\":\"F04.\",\"NAME\":\"014.父流程(自动发起子流程)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"015\",\"PARENTNO\":\"F04.\",\"NAME\":\"015.子流程A\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"018\",\"PARENTNO\":\"F107\",\"NAME\":\"018.请假流程(SDK模式)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"023\",\"PARENTNO\":\"F06.\",\"NAME\":\"023.最简单的3节点(轨迹模式)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"024\",\"PARENTNO\":\"F06.\",\"NAME\":\"024.最简单的3节点(覆盖模式)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"028\",\"PARENTNO\":\"F109\",\"NAME\":\"028.测试方向条件-部门方向条件\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"029\",\"PARENTNO\":\"F109\",\"NAME\":\"029.测试方向条件-开发者参数\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"030\",\"PARENTNO\":\"F109\",\"NAME\":\"030.测试方向条件-按SQL\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"032\",\"PARENTNO\":\"F07.\",\"NAME\":\"032.节点属性-超时处理\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"033\",\"PARENTNO\":\"F02.\",\"NAME\":\"033.具有质量考核的同表单流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"036\",\"PARENTNO\":\"F07.\",\"NAME\":\"036.阅读回执-请假流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"038\",\"PARENTNO\":\"F02.\",\"NAME\":\"038.工作计划(具有明细表汇总)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"044\",\"PARENTNO\":\"F02.\",\"NAME\":\"044.具有两段同表单分合流并且汇总明细表Demo\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"045\",\"PARENTNO\":\"F02.\",\"NAME\":\"045.具有两段同表单分合流Demo\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"050\",\"PARENTNO\":\"F02.\",\"NAME\":\"050.两段分合流子线程集合不一致\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"054\",\"PARENTNO\":\"F07.\",\"NAME\":\"054.找人规则(找领导)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"055\",\"PARENTNO\":\"F102\",\"NAME\":\"055.学生请假流程(Guest流程)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"056\",\"PARENTNO\":\"F108\",\"NAME\":\"056.跳转1-处理人就是提交人1-1\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"057\",\"PARENTNO\":\"F108\",\"NAME\":\"057.跳转1-处理人就是提交人1-2\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"062\",\"PARENTNO\":\"F108\",\"NAME\":\"062.跳转1-处理人就是提交人1-3\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"063\",\"PARENTNO\":\"F108\",\"NAME\":\"063.跳转2-处理人出现过\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"068\",\"PARENTNO\":\"F01.\",\"NAME\":\"068.共享任务测试\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"069\",\"PARENTNO\":\"F02.\",\"NAME\":\"069.以明细表做接受人与数据源\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"071\",\"PARENTNO\":\"F01.\",\"NAME\":\"071.批量发起,批量审核\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"074\",\"PARENTNO\":\"F07.\",\"NAME\":\"074.测试表单字段类型流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"075\",\"PARENTNO\":\"F109\",\"NAME\":\"075.测试方向条件-按URL\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"079\",\"PARENTNO\":\"F01.\",\"NAME\":\"079.批量发起-分组审核-启动父流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"080\",\"PARENTNO\":\"F01.\",\"NAME\":\"080.批量发起-分组审核父流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"081\",\"PARENTNO\":\"F09.\",\"NAME\":\"081.简单导航-单条模式\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"082\",\"PARENTNO\":\"F09.\",\"NAME\":\"082.导航测试-立项流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"083\",\"PARENTNO\":\"F09.\",\"NAME\":\"083.导航测试-项目单条验收(子流程)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"084\",\"PARENTNO\":\"F112\",\"NAME\":\"084.树形表单-立项申请\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"085\",\"PARENTNO\":\"F112\",\"NAME\":\"085.树形表单-项目验收\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"086\",\"PARENTNO\":\"F09.\",\"NAME\":\"086.导航测试-项目合并验收(父流程)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"099\",\"PARENTNO\":\"F02.\",\"NAME\":\"099.两个子线程分合流\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"110\",\"PARENTNO\":\"F107\",\"NAME\":\"110.请假流程(审批组件模式)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"114\",\"PARENTNO\":\"F05.\",\"NAME\":\"114.同表单分合流\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"115\",\"PARENTNO\":\"F05.\",\"NAME\":\"115.同表单分合流(子流程)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"116\",\"PARENTNO\":\"F07.\",\"NAME\":\"116.公文接受人模式\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"117\",\"PARENTNO\":\"F104\",\"NAME\":\"117.多人待办工作处理模式\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"118\",\"PARENTNO\":\"F103\",\"NAME\":\"118.请假流程(审核组件-自由表单)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"119\",\"PARENTNO\":\"F109\",\"NAME\":\"119.节点手工方向选择\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"120\",\"PARENTNO\":\"F01.\",\"NAME\":\"120.自由流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"121\",\"PARENTNO\":\"F01.\",\"NAME\":\"121.自由流程-子流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"122\",\"PARENTNO\":\"F02.\",\"NAME\":\"122.一人多子线程模式(批次维度任务模式)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"123\",\"PARENTNO\":\"F111\",\"NAME\":\"123.请假流程(轨迹模式)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"124\",\"PARENTNO\":\"F08.\",\"NAME\":\"124.请假流程(数据合并模式)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"125\",\"PARENTNO\":\"F111\",\"NAME\":\"125.傻瓜表单工作模式\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"126\",\"PARENTNO\":\"F111\",\"NAME\":\"126.自由表单-审核组件-请假流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"127\",\"PARENTNO\":\"F111\",\"NAME\":\"127.Word表单-请假流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"128\",\"PARENTNO\":\"F111\",\"NAME\":\"128.Excel表单-请假流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"129\",\"PARENTNO\":\"F111\",\"NAME\":\"129.嵌入式表单流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"130\",\"PARENTNO\":\"F105\",\"NAME\":\"130.节点发送阻塞测试\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"131\",\"PARENTNO\":\"F112\",\"NAME\":\"131.Office类型表单权限控制demo\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"132\",\"PARENTNO\":\"F114\",\"NAME\":\"132.公文流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"134\",\"PARENTNO\":\"F110\",\"NAME\":\"134.人员入职申请单\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"135\",\"PARENTNO\":\"F110\",\"NAME\":\"135.人员部门岗位变更\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"137\",\"PARENTNO\":\"F107\",\"NAME\":\"137.请假流程(自定义表单)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"138\",\"PARENTNO\":\"F02.\",\"NAME\":\"138.煤矿安检流程(从表分流)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"139\",\"PARENTNO\":\"F03.\",\"NAME\":\"139.订单流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"142\",\"PARENTNO\":\"F106\",\"NAME\":\"142.主流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"143\",\"PARENTNO\":\"F106\",\"NAME\":\"143.子流程1\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"144\",\"PARENTNO\":\"F106\",\"NAME\":\"144.子流程2\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"145\",\"PARENTNO\":\"F106\",\"NAME\":\"145.孙子流程1\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"146\",\"PARENTNO\":\"F106\",\"NAME\":\"146.孙子流程2\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"147\",\"PARENTNO\":\"F07.\",\"NAME\":\"147.工业自动化流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"149\",\"PARENTNO\":\"F114\",\"NAME\":\"149.公文收文\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"150\",\"PARENTNO\":\"F114\",\"NAME\":\"150.公文发文\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"151\",\"PARENTNO\":\"F104\",\"NAME\":\"151.多人处理规则\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"157\",\"PARENTNO\":\"F02.\",\"NAME\":\"157.独立表单数据汇总\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"158\",\"PARENTNO\":\"F112\",\"NAME\":\"158.动态绑定多表单流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"163\",\"PARENTNO\":\"F09.\",\"NAME\":\"163.自定义URL前置导航\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"164\",\"PARENTNO\":\"F02.\",\"NAME\":\"164.子线程可以查看分流点明细表\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"165\",\"PARENTNO\":\"F112\",\"NAME\":\"165.以表单字段为条件启用禁用独立表单\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"166\",\"PARENTNO\":\"F104\",\"NAME\":\"166.特别控件特别用户权限-附件类\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"167\",\"PARENTNO\":\"F104\",\"NAME\":\"167.多部门联合审批(协作模式)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"168\",\"PARENTNO\":\"F115\",\"NAME\":\"168.分段项目申请(子流程)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"169\",\"PARENTNO\":\"F115\",\"NAME\":\"169.总承包项目合卷审批(父流程)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"170\",\"PARENTNO\":\"F01.\",\"NAME\":\"170.接受人自定义\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"177\",\"PARENTNO\":\"F01.\",\"NAME\":\"177.请假流程(傻瓜表单模式)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"183\",\"PARENTNO\":\"F109\",\"NAME\":\"183.发送前下拉框选择(傻瓜表单)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"184\",\"PARENTNO\":\"F109\",\"NAME\":\"184.发送前下拉框选择(自由表单)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"185\",\"PARENTNO\":\"F01.\",\"NAME\":\"185.选择人接收器\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"195\",\"PARENTNO\":\"F111\",\"NAME\":\"195.请假流程-傻瓜表单-审核组件模式\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"196\",\"PARENTNO\":\"F01.\",\"NAME\":\"196.延续流程主流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"197\",\"PARENTNO\":\"F01.\",\"NAME\":\"197.延续流程子流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"201\",\"PARENTNO\":\"F103\",\"NAME\":\"201.独立表单审核组件流程\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"203\",\"PARENTNO\":\"F101\",\"NAME\":\"203.会签-协作模式\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"204\",\"PARENTNO\":\"F101\",\"NAME\":\"204.会签-组长模式\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0},{\"NO\":\"205\",\"PARENTNO\":\"F100\",\"NAME\":\"205.财务报销演示(傻瓜表单)\",\"IDX\":0,\"ISPARENT\":0,\"TTYPE\":\"FLOW\",\"DTYPE\":0}]";
    }
    public function GetTreeJsonAdminMenu()
    {
        return "[{\"No\":\"System\",\"Url\":\"\",\"Name\":\"系统管理\",\"GroupNo\":\"0\",\"For\":null},{\"No\":\"Org\",\"Url\":\"\",\"Name\":\"组织结构\",\"GroupNo\":\"0\",\"For\":null},{\"No\":\"GPM\",\"Url\":\"\",\"Name\":\"菜单权限\",\"GroupNo\":\"0\",\"For\":null},{\"No\":\"002\",\"Url\":\"../../Comm/Sys/Holiday.htm\",\"Name\":\"节假日设置\",\"GroupNo\":\"System\",\"For\":\"admin\"},{\"No\":\"003\",\"Url\":\"../../Comm/Sys/SystemClass.htm\",\"Name\":\"表结构\",\"GroupNo\":\"System\",\"For\":\"admin\"},{\"No\":\"004\",\"Url\":\"../../Comm/Search.htm?EnsName=BP.WF.Port.SubInc.AdminEmps\",\"Name\":\"二级管理员\",\"GroupNo\":\"System\",\"For\":\"admin\"},{\"No\":\"005\",\"Url\":\"../../Comm/MethodLink.htm\",\"Name\":\"工具箱\",\"GroupNo\":\"System\",\"For\":\"admin\"},{\"No\":\"010\",\"Url\":\"../../Setting/ChangePassword.htm\",\"Name\":\"修改密码\",\"GroupNo\":\"System\",\"For\":\"admin\"},{\"No\":\"020\",\"Url\":\"../../Comm/Sys/JavaScriptImp.htm\",\"Name\":\"JavaScript脚本导入\",\"GroupNo\":\"System\",\"For\":\"\"},{\"No\":\"001\",\"Url\":\"../../Comm/Search.htm?EnsName=BP.WF.Template.SQLTemplates\",\"Name\":\"SQL配置模版设置\",\"GroupNo\":\"System\",\"For\":\"admin\"},{\"No\":\"504\",\"Url\":\"../../../GPM/Organization.htm\",\"Name\":\"组织结构\",\"GroupNo\":\"Org\",\"For\":\"admin\"},{\"No\":\"501\",\"Url\":\"../../Comm/Search.htm?EnsName=BP.WF.Port.Incs\",\"Name\":\"独立组织\",\"GroupNo\":\"Org\",\"For\":\"admin\"},{\"No\":\"504\",\"Url\":\"../../Comm/Search.htm?EnsName=BP.En.Groups\",\"Name\":\"权限组\",\"GroupNo\":\"Org\",\"For\":\"admin\"},{\"No\":\"501\",\"Url\":\"../../Comm/Search.htm?EnsName=BP.GPM.StationTypes\",\"Name\":\"岗位类型维护\",\"GroupNo\":\"Org\",\"For\":\"admin\"},{\"No\":\"501\",\"Url\":\"../../Comm/Search.htm?EnsName=BP.GPM.Stations\",\"Name\":\"岗位维护\",\"GroupNo\":\"Org\",\"For\":\"admin\"},{\"No\":\"502\",\"Url\":\"../../Comm/Search.htm?EnsName=BP.GPM.Depts\",\"Name\":\"部门台帐\",\"GroupNo\":\"Org\",\"For\":\"admin\"},{\"No\":\"503\",\"Url\":\"../../Comm/Search.htm?EnsName=BP.GPM.Emps\",\"Name\":\"人员台帐\",\"GroupNo\":\"Org\",\"For\":\"\"},{\"No\":\"901\",\"Url\":\"../../Comm/Search.htm?EnsName=BP.GPM.AppSorts\",\"Name\":\"系统类别\",\"GroupNo\":\"GPM\",\"For\":\"\"},{\"No\":\"902\",\"Url\":\"../../Comm/Search.htm?EnsName=BP.GPM.Apps\",\"Name\":\"系统台帐\",\"GroupNo\":\"GPM\",\"For\":\"\"},{\"No\":\"903\",\"Url\":\"../../Comm/Search.htm?EnsName=BP.GPM.Groups\",\"Name\":\"权限组菜单\",\"GroupNo\":\"GPM\",\"For\":\"\"},{\"No\":\"904\",\"Url\":\"../../Comm/Search.htm?EnsName=BP.GPM.StationExts\",\"Name\":\"岗位菜单\",\"GroupNo\":\"GPM\",\"For\":\"\"},{\"No\":\"905\",\"Url\":\"../../Comm/Search.htm?EnsName=BP.GPM.GPMEmps\",\"Name\":\"人员菜单\",\"GroupNo\":\"GPM\",\"For\":\"\"},{\"No\":\"907\",\"Url\":\"../../Comm/Tree.htm?EnsName=BP.GPM.Menus\",\"Name\":\"菜单树\",\"GroupNo\":\"GPM\",\"For\":\"\"}]";
    }

	public function loginSubmit()
	{
		//string[] para = new string[0];
		$para=array();
		//BP.Port.Emp emp = new BP.Port.Emp();
		$emp=new \BP\Port\Emp();
		//emp.No = this.GetRequestVal("TB_No").Trim();
		$emp->No=trim(Request::instance()->get('TB_No'));
		
		//if (emp.RetrieveFromDBSources() == 0)
		if ($emp->RetrieveFromDBSources() == 0)
			return "err@用户名或密码错误.";
        /*
		if (emp.No != "admin")
		{
			//检查是否是管理员？
			BP.WF.Port.AdminEmp adminEmp = new Port.AdminEmp();
			adminEmp.No = emp.No;
			if (adminEmp.RetrieveFromDBSources() == 0)
				return "err@您非管理员用户，不能登录.";
			//return BP.WF.Glo.lang("no_permission_login_1", para);

			if (adminEmp.IsAdmin == false)
				return "err@您非管理员用户或已被禁用,不能登录,请联系管理员初始化账户.";
				//return BP.WF.Glo.lang("no_permission_login_2", para);

			if (string.IsNullOrWhiteSpace(adminEmp.RootOfFlow) == true)
				return "err@二级管理员用户没有设置流程树的权限..";
			//return BP.WF.Glo.lang("secondary_user_no_permission_wf_tree", para);
		}

		string pass = this.GetRequestVal("TB_PW").Trim();
		if (emp.CheckPass(pass) == false)
			return "err@用户名或密码错误.";
		//return BP.WF.Glo.lang("invalid_username_or_pwd", para);

		//让其登录.
		BP.WF.Dev2Interface.Port_Login(emp.No);*/
		return "url@Default.htm?SID=" . $emp->SID . "&UserNo=" . $emp->No;
	}
	//
	public function loginInit()
	{
        /*
        原始c#代码
     //检查数据库连接.
        try
        {
                DBAccess.TestIsConnection();
        }
        catch (Exception ex)
        {
            return "err@异常信息:" + ex.Message;
        }


        //检查是否缺少Port_Emp 表，如果没有就是没有安装.
        if (DBAccess.IsExitsObject("Port_Emp") == false && DBAccess.IsExitsObject("WF_Flow") == false)
            return "url@../DBInstall.htm";

        //如果没有流程表，就执行安装.
        if (BP.DA.DBAccess.IsExitsObject("WF_Flow") == false)
            return "url@../DBInstall.htm";

        //是否需要自动登录
        string userNo = this.GetRequestVal("UserNo");
        string sid = this.GetRequestVal("SID");

        if (sid != null && userNo != null)
        {
            try
            {
                string str = BP.WF.Glo.UpdataCCFlowVer();

                BP.WF.Dev2Interface.Port_Login(userNo, sid);
                if (this.FK_Flow == null)
                    return "url@Default.htm?UserNo=" + userNo + "&Key=" + DateTime.Now.ToBinary();
                else
                    return "url@Designer.htm?UserNo=" + userNo + "&FK_Flow=" + this.FK_Flow + "&Key=" + DateTime.Now.ToBinary();
            }
            catch (Exception ex)
            {
                return "err@登录失败";
            }
        }

        try
        {
            // 执行升级
            string str = BP.WF.Glo.UpdataCCFlowVer();
            if (str == null)
                str = "ccbpm 准备完毕,欢迎登录,当前小版本号为:" + BP.WF.Glo.Ver;

            return str;
        }
        catch (Exception ex)
        {
            string msg = "err@升级失败(ccbpm有自动修复功能,您可以刷新一下系统会自动创建字段,刷新多次扔解决不了问题,请反馈给我们.www.ccflow.org)";
            msg += "@系统信息:" + ex.Message;
            return msg;
        }
        */
            try{
                //先支持一下mysql，再从长计议
                DBAccess::TestIsConnection();
             }
             catch(\Exception $e)
             {
                return "err@异常信息".$e->getMessage();
              }

              //检查是否缺少Port_Emp 表，如果没有就是没有安装.
              if (DBAccess::IsExitsObject("Port_Emp") == false && DBAccess::IsExitsObject("WF_Flow") == false)
              return "url@../DBInstall.htm";

            //如果没有流程表，就执行安装.
            if (DBAccess::IsExitsObject("WF_Flow") == false)
            return "url@../DBInstall.htm";

            //是否需要自动登录
            $request=Request::instance();
            $userNo = $request->get('UserNo');
            $sid = $request->get('SID');
             if ($sid != null && $userNo != null)
            {
                try
                {
                    $str = \BP\WF\Glo::UpdataCCFlowVer();

                    BP.WF.Dev2Interface.Port_Login(userNo, sid);
                    if (this.FK_Flow == null)
                        return "url@Default.htm?UserNo=" . $userNo . "&Key=" . time();
                    else
                        return "url@Designer.htm?UserNo=" . $userNo . "&FK_Flow=" . $this->FK_Flow . "&Key=" . time();
                }
                catch (\Exception $ex)
                {
                    return "err@登录失败";
                }
            }

            try
            {

                // 执行升级
                $str = \BP\WF\Glo::UpdataCCFlowVer();
                if ($str == null)
                    $str = "ccbpm 准备完毕,欢迎登录,当前小版本号为:" . \BP\WF\Glo::$Ver;
                return $str;
            }
            catch (\Exception $ex)
            {
                $msg = "err@升级失败(ccbpm有自动修复功能,您可以刷新一下系统会自动创建字段,刷新多次扔解决不了问题,请反馈给我们.www.ccflow.org)";
                $msg =$msg. "@系统信息:" . $ex->getMessage();
                return $msg;
            }
	}
}